/*****************************************************************************
 *
 *                      HUSONG PROPRIETARY INFORMATION
 *
 *          The information contained herein is proprietary to HUSONG
 *           and shall not be reproduced or disclosed in whole or in part
 *                    or used for any design or manufacture
 *              without direct written authorization from HUSONG.
 *
 *            Copyright (c) 2015 by HUSONG.  All rights reserved.
 *
 *****************************************************************************/
package me.send.business.service.service;

import java.util.HashMap;
import java.util.Map;

import me.send.business.service.BaseService;
import me.send.business.service.bean.ReturnBean;
import me.send.business.service.mapper.OrderBrokerMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author maxmin
 *
 * @date 2015年8月7日 上午11:12:33
 */
@Service
public class OrderBrokerService extends BaseService{
	
	@Autowired
	OrderBrokerMapper orderBrokerMapper;
	
	public int checkBroker(Long orderBrokerId,int orderid,String devicenumber){
		if (isDevicenumber(devicenumber)) {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("orderBrokerId", orderBrokerId);
			int result = orderBrokerMapper.checkBroker(params);
			int brokerId=orderBrokerMapper.getBrokerIdByOrderBrokerId(orderBrokerId);
//			orderBrokerMapper.updateOrderStatus(orderid);
			
			Map<String, Object> p = new HashMap<String, Object>();
			p.put("orderid", orderid);
			p.put("brokerid", brokerId);
			orderBrokerMapper.updateOrderStatusAndBrokerId(p);
			
			return result;
		}
		return ReturnBean.FAIL;
	}
	
	public String getBrokerNoticIdByOrderBrokerId(Long orderBrokerId){
		return orderBrokerMapper.getBrokerNoticIdByOrderBrokerId(orderBrokerId);
	}
	
	public int getBrokerIdByOrderBrokerId(Long orderBrokerId){
		return orderBrokerMapper.getBrokerIdByOrderBrokerId(orderBrokerId);
	}
}
